package es.uned.hoomgle.web.actions;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;

import com.opensymphony.xwork2.ActionSupport;

import es.uned.hoomgle.core.dtos.UserDto;
import es.uned.hoomgle.core.services.interfaces.UserServiceI;


@ResultPath(value="/")
public class WelcomeAction extends ActionSupport{
 
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String username;
	
	@Resource
	private UserServiceI userService;
 
	public String getUsername() {
		return username;
	}
 
	public void setUsername(String username) {
		this.username = username;
	}
 
	@Action(results={
		@Result(name="success",location="index.jsp")
	})
	public String welcome() {
		UserDto userDto = new UserDto();
		userDto.setName(username);
		userService.save(userDto);
		System.out.println("welcome execute");
		return SUCCESS;
 
	}
}
